using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerJumpState : PlayerAbilityState
{
    private int jumpCounter;

    public PlayerJumpState(Player player, PlayerMoveData playerData, StateMachine stateMachine, string animBoolName) : base(player, playerData, stateMachine, animBoolName)
    {
    }

    public override void Enter()
    {
        base.Enter();
        player.inputHandler.JumpInput = false;
        if (stateMachine.LastState == player.CrouchIdleState || stateMachine.LastState == player.CrouchMoveState)
        {
            player.SetVelocityY(playerData.jumpVelocity * playerData.crouchJumpMultiplier); 
        }
        else 
        {
            player.SetVelocityY(playerData.jumpVelocity);
        }
        
        isAbilityDone = true;
        player.InAirState.SetIsJumping();
        jumpCounter--;
    }

    public bool CanJump() 
    {
        return jumpCounter > 0;
    }

    public void ResetJumpCount() 
    {
        jumpCounter = playerData.maxJumpCount;
    }

    public void SetJumpCountZero() 
    {
        jumpCounter = 0;
    }
}
